<script src="${ctxPath}/static/js/lay/modules/element.js"></script>
<blockquote class="layui-elem-quote" style="font-size: 14px">专家人才积分规则

</blockquote>
<hr class="layui-bg-gray">
<form class="layui-form" action="" id="expert_form">
    <div class="layui-collapse" lay-filter="expert_collapse">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">国家级</h2>
            <div class="layui-colla-content layui-show">

                <table class="layui-table">
                    <colgroup>
                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="5%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addCountryRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="country_table">
                    @for(cr in countryRules){
                    <tr>
                        <td><input type="text" name="countryRule[${crLP.index}].grade" value="${cr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="countryRule[${crLP.index}].gradeCode" value="${cr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="countryRule[${crLP.index}].integral" value="${cr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">省部（行业）级</h2>
            <div class="layui-colla-content">


                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addProvinceViceGridRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="provinceVice_table">
                    @for(pvr in provinceViceRules){
                    <tr>
                        <td><input type="text" name="provinceViceRule[${pvrLP.index}].grade" value="${pvr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="provinceViceRule[${pvrLP.index}].gradeCode" value="${pvr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="provinceViceRule[${pvrLP.index}].integral" value="${pvr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">国网公司级</h2>
            <div class="layui-colla-content">


                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addStateGridRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="stateGrid_table">
                    @for(sgr in stateGridRules){
                    <tr>
                        <td><input type="text" name="stateGridRule[${sgrLP.index}].grade" value="${sgr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="stateGridRule[${sgrLP.index}].gradeCode" value="${sgr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="stateGridRule[${sgrLP.index}].integral" value="${sgr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">省公司级</h2>
            <div class="layui-colla-content">

                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addProvinceRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="province_table">
                    @for(pr in provinceRules){
                    <tr>
                        <td><input type="text" name="provinceRule[${prLP.index}].grade" value="${pr.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="provinceRule[${prLP.index}].gradeCode" value="${pr.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="provinceRule[${prLP.index}].integral" value="${pr.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">地市（厅局）级</h2>
            <div class="layui-colla-content">

                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addCityViceRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="cityVice_table">
                    @for(civi in cityViceRules){
                    <tr>
                        <td><input type="text" name="cityViceRule[${civiLP.index}].grade" value="${civi.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="cityViceRule[${civiLP.index}].gradeCode" value="${civi.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="cityViceRule[${civiLP.index}].integral" value="${civi.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="layui-colla-item">
            <h2 class="layui-colla-title">地市公司级</h2>
            <div class="layui-colla-content">

                <table class="layui-table">
                    <colgroup>

                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="1%">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>级别</th>
                        <th>代码</th>
                        <th>积分</th>
                        <th>
                            <button type="button" class="btn btn-primary " onclick="addCityRow()" >
                                <i class="fa fa-plus-circle"></i>
                            </button>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="city_table">
                    @for(city in cityRules){
                    <tr>
                        <td><input type="text" name="cityRule[${cityLP.index}].grade" value="${city.grade}"  autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="cityRule[${cityLP.index}].gradeCode" value="${city.gradeCode}" autocomplete="off" class="layui-input" lay-verify="required"></td>
                        <td><input type="text" name="cityRule[${cityLP.index}].integral" value="${city.integral}" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
                        <td>
                            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                                <i class="fa fa-trash-o"></i>
                            </button>
                        </td>
                    </tr>
                    @}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block" style="margin-top: 20px;">

            <button class="layui-btn" lay-submit lay-filter="expert_form" >提交保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<template>
    <tr>
        <td><input type="text" name="[].grade" autocomplete="off" class="layui-input" lay-verify="required"></td>
        <td><input type="text" name="[].gradeCode" autocomplete="off" class="layui-input" lay-verify="required"></td>
        <td><input type="text" name="[].integral" autocomplete="off" class="layui-input" lay-verify="required|number"></td>
        <td>
            <button type="button" class="btn btn-primary " onclick="deleteRow($(this))">
                <i class="fa fa-trash-o"></i>
            </button>
        </td>
    </tr>
</template>
<script>
    $(function(){
        initFullTimeTrain();
    });

    function initFullTimeTrain() {
        layui.use(['layer', 'form'], function(){
            var element = layui.element;
            var layer = layui.layer;
            var form = layui.form;

            //监听折叠
            element.on('collapse(expert_collapse)', function(data){

            });

            form.on('submit(expert_form)', function(data){
                form.verify();
                $.ajax({
                    type: "POST",
                    url: 'integral/expert_train_add',
                    data: data.field,
                    dataType: "json",
                    success: function(data){
                        Feng.success("保存成功!");
                    }
                });
                return false;
            });
        });

    }


    function deleteRow($this) {
        $this.closest("tr").empty();
    }


    /**
     * 经营添加行
     */
    function addCountryRow() {
        var trSize = $("#country_table>tr").length + 1;
        $("#country_table").append($("template").html().replace(/\[]/g,"countryRule["+trSize+"]"));
    }

    function addProvinceViceGridRow() {
        var trSize = $("#provinceVice_table>tr").length + 1;
        $("#provinceVice_table").append($("template").html().replace(/\[]/g,"provinceViceRule["+trSize+"]"));
    }

    function addCityViceRow() {
        var trSize = $("#cityVice_table>tr").length + 1;
        $("#cityVice_table").append($("template").html().replace(/\[]/g,"cityViceRule["+trSize+"]"));
    }

    /**
     * 管理添加行
     */
    function addStateGridRow() {
        var trSize = $("#stateGrid_table>tr").length + 1;
        $("#stateGrid_table").append($("template").html().replace(/\[]/g,"stateGridRule["+trSize+"]"));
    }

    /**
     * 技术人员
     */
    function addProvinceRow() {
        var trSize = $("#province_table>tr").length + 1;
        $("#province_table").append($("template").html().replace(/\[]/g,"provinceRule["+trSize+"]"));
    }

    /**
     * 技能人员
     */
    function addCityRow() {
        var trSize = $("#city_table>tr").length + 1;
        $("#city_table").append($("template").html().replace(/\[]/g,"cityRule["+trSize+"]"));
    }


</script>
